package com.it.mapper;

import com.it.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface StudentMapper {
    // 查询 全部学生信息
    @Select("select id, name, gender, age, class 'classes' from student limit ${index},${size};")
    List<Student> queryAllMapper(@Param("index") int index, @Param("size") int size);

    // 查询 根据年龄查询
    @Select("select id, name, gender, age, class from student where age = #{age};")
    List<Student> qyeryAgeMapper(@Param("age") int ageNum);


    // 根据 根据性别查询
    @Select("select id, name, gender, age, class from student where gender =#{gender}")
    List<Student> qyeryGenderMapper(@Param("gender") String genderNum);


    // 新增 一个学生信息
    @Insert("insert into student ( name, gender, age, class) value (#{name},#{gender},#{age},#{classes})")
    int addStuMapper(Student student);

    // 删除一条学生数据
    @Delete("delete from student where id=#{id}")
    int delStuMapper(@Param("id") int id);

    // 修改一条学生数据
    @Update("update student set name=#{stu.name},gender=#{stu.gender},age=#{stu.age},class =#{stu.classes} where id=#{stu.id};")
    int putStuMapper(@Param("stu") Student student);
}
